home *** CD-ROM | disk | FTP | other *** search
-
- -- Random integer generator class
-
- indexing
- author: "Guichard Damien";
- created: 7,November,1995;
- modified: 7,Novemeber,1995
-
- class RANDOM
- creation {ANY}
- randomize
- feature {ANY}
- randomize (seed:INTEGER) is
- -- Reset random value.
- do
- z := seed
- ensure
- -- z = seed
- end; -- randomize
- random:INTEGER is
- -- Compute next random value.
- local gamma:INTEGER
- do
- gamma := a * (z \\ q) - r * (z // q)
- if gamma > 0 then
- z := gamma
- else
- z := gamma + m
- end
- Result := z // m
- end -- random
- feature {NONE}
- z:INTEGER;
- a:INTEGER is 16_807;
- m:INTEGER is 2_147_483_647;
- q:INTEGER is 127_773;
- r:INTEGER is 2_836
- end -- class 'RANDOM'
-
-